#ifndef __RED_FRAME_OBJECT_H__
#define __RED_FRAME_OBJECT_H__

#include "redobject.h"

#define FRAME_STACK_SIZE		128
#define FRAME_RECURSIVE_MAX		1024

typedef struct _RedFrameBlock
{
	int				  pb;
	int				 *ssp;
	RedObject		**blocks;
	int				  capacity;
} RedFrameBlock;

typedef struct _RedFrameObject
{
	RedObject_HEAD

	int				  pc;
	int				  sp;
	int				  asp;
	RedObject		 *code;
	RedObject		**stack;
	RedObject		 *parent;
	RedFrameBlock	  blocks;
	RedObject		 *locals;
	RedObject		 *closure;
	int				  capacity;
} RedFrameObject;

RED_EXPORT extern RedTypeObject RedType_Frame;

#define RedFrame_PC(o)			(((RedFrameObject *)(o))->pc)
#define RedFrame_Code(o)		(((RedFrameObject *)(o))->code)
#define RedFrame_Locals(o)		(((RedFrameObject *)(o))->locals)

RED_EXPORT RedObject *RedFrame_Acquire(RedObject *code, RedObject *locals, RedObject *closure);

#endif /* __RED_FRAME_OBJECT_H__ */
